const { db, query } = require("../../db/db");
const util = require("util");
async function GetUserInfo(req, res) {
  const UserId = Number(req.params.username);
  const select_user_list_sql = util.format(
    "Select \
   IFNULL(UserName,'') as UserName, \
   IFNULL(HeaderImg,'') as HeaderImg, \
   IFNULL(SelfDescription,'') as SelfDescription, \
   Follow, \
   Fans, \
   IFNULL(ArticleNum,'') as ArticleNum, \
   IFNULL(ActionWorkTime,'') as ActionWorkTime, \
   WorkId, \
   IFNULL(WorkName,'') as WorkName, \
   IFNULL(Company,'') as Company, \
   IFNULL(MyHomeUrl,'') as MyHomeUrl, \
   IFNULL(IntertesTab,'') as IntertesTab \
   From  User where UserId=%s",
    UserId
  );

  const select_user_list_sql_res = await query(select_user_list_sql);

  /*  if(select_user_list_sql[0]){
    const IntertesTab=select_user_list_sql_res[0].IntertesTab.split(',')
  } */
  res.send({
    status: 0,
    UserInfo: {
      ...select_user_list_sql_res[0],
      IntertesTab: select_user_list_sql_res[0].IntertesTab.split(","),
    },
  });
}

module.exports = { GetUserInfo };
